<?php 
	$product_details = $this->product_details ;
	$list_images = $this->list_image ;
	$methods = $this->methods ;
	$qty = $this->qty ;
	$outlets = $this->outlets;
?>
<script>
	jQuery(document).ready(function() {
		jQuery(".header").hide();
		jQuery(".footer").hide();
		jQuery(".menu").hide();
		
		// clear cart
		jQuery("#clearCart2").click(function() {
			var url = "<?php echo JRoute::_("index.php?option=com_wrd&view=redemption&layout=cart")?>";
			jQuery.get(url, function(data) {
				  jQuery.facebox(data);
			});
		});
		
		// submit cart
		jQuery("#submitCart2").click(function() {
			var res = jQuery("#pick_up_at").val();
			if (res == '') {
				alert('<?php echo JText::_('WRD_PROMOTION_ALERT_PLEASE_CHOOSE_AN_OUTLET')?>');
				return false;
			}
			
			var url = "<?php echo JRoute::_("index.php?option=com_wrd&view=redemption&layout=redeem&res=")?>" + res;
			jQuery.get(url, function(data) {
				  jQuery.facebox(data);
			});

			return false;
		});
	});
</script>
<h2 class="arrow_left_bg">CONFIRMATION DETAILS</h2>
<div id="ajax-loading-ck">
		<div class="selectProvider">
			<a name="listTop"></a>
			<div class="tools top">
				<table width="100%" cellspacing="0" cellpadding="0">
					<tbody>
						<tr>
							<td width="160"><span><h2><?php echo $this->cat_name ; ?></h2></span></td>
							<td width="145"></td>
						</tr>
					</tbody>
				</table>
			</div>
				<div class="SPList">
					<div id="selectad" class="selectad s1 "></div>
					<?php $i=0;
							foreach($product_details as $product):
								$images = $list_images[$product->id];
					?>
					<div class="sp">
						<ul style="list-style-type: none;">
							<li class="sp-image">
								<div class="image">
									<a href="index.php?option=com_wrd&view=redemption&layout=product&cid=<?php echo $product->cat_id ; ?>&pid=<?php echo $product->id ; ?>&Itemid=126">
										<img src="wrd/thumb/<?php echo $images->file_name ;?>" class="productImage" alt="Product Details">
									</a>
								</div>
							</li>
							<li class="sp-id">
								<p class="sp-name">
									<a class="title" href="index.php?option=com_wrd&view=redemption&layout=product&cid=<?php echo $product->cat_id ; ?>&pid=<?php echo $product->id ; ?>&Itemid=126">
										<?php echo $product->products_name ; ?>
									</a>
								</p>
								<span class="sp-expertise">
									<?php 
                                                if(!empty($product->point)){
                                                    echo 'Normal: '.$product->point.' Points' ; 
                                                }
                                    ?>        
								</span>
								<span class="sp-expertise">
									<?php 
                                                if(!empty($product->pointx)){ 
                                                    echo "Fast Track: ".$product->pointx ;  ?> Points + <?php echo $product->cash ; ?> VND<?php 
                                                } 
                                     ?>
								</span>
							</li>
						</ul>
						<div style="position: absolute;margin-left: 500px;">
							<br/>
							<font size='5' color='blue'>
								<?php 
                                	if($methods[$product->id] == 'p'){
                                		$total_point += $product->point * $qty[$product->id];
                                    	echo $product->point * $qty[$product->id];
                                	}
                                ?>
                                <?php 
                                	if($methods[$product->id] == 'pm'){
                                		$total_point += $product->pointx * $qty[$product->id];
                                    	echo $product->pointx * $qty[$product->id];
                                	}
                                ?>pts
							</font>
							<hr />
							<font size='5'color='red'>
								<?php 
                                	if($methods[$product->id] == 'pm'){
                                		$total_cash += $product->cash * $qty[$product->id]; 
                                    	echo $product->cash * $qty[$product->id]; 
                                ?> vnd
                                <?php 
                                	}
                                ?>
							</font>
						</div>
					</div>
					<?php $i++;
							endforeach;
					?>
					<div class="sp">
						<ul style="list-style-type: none;">
							<li class="sp-image">
							</li>
							<li class="sp-id" style="height: 110px;"></li>
						</ul>
						<div id="shortDesc<?php echo $i;?>" style="position: absolute;margin-left: 500px;">
							<br/>
							<font size='2' color='blue'>
								Your points: <?php echo $this->p_o_u; ?> pts
							</font>
							<br/>
							<font size='2' color='red'>
								Total points: <?php echo $total_point; ?> pts
							</font>
							<hr />
							<font size='2'color='red'>
								Point balance: <?php echo $this->p_o_u - $total_point; ?> pts
							</font>
							<br/>
							<font size='2'color='red'>
								<?php 
                                	if($total_cash > 0){
                                		echo 'Cash balance: '.$total_cash.' vnd';
                                	}
                                ?>
							</font>
							<br/>
							Choose an outlet: <?php echo $outlets;?>
						</div>
					</div>
				</div>
			<div class="sp-join">
				<button id="submitCart2">Redeem now</button>
				<a href="###" style="float: right; margin-top: 2px">&nbsp;</a>
				<button id="clearCart2">Edit cart</button>
			</div>
		</div>
</div>